/**
 * Render Bender - A Flash-based chained Pixel Bender kernel previewer
 * Copyright (C) 2009  David Lenaerts
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Author information:
 * David Lenaerts
 * url: http://www.derschmale.com
 * mail: david.lenaerts@gmail.com
 * 
 */
 
package com.derschmale.renderBender
{
	import com.derschmale.renderBender.controller.BrowseXMLCommand;
	import com.derschmale.renderBender.controller.CreateSequenceCommand;
	import com.derschmale.renderBender.controller.ExecuteSequenceCommand;
	import com.derschmale.renderBender.controller.LoadDefinitionCommand;
	import com.derschmale.renderBender.controller.ResetAssetsCommand;
	import com.derschmale.renderBender.controller.SetAsynchronousCommand;
	import com.derschmale.renderBender.controller.StartupCommand;
	import com.derschmale.renderBender.controller.UploadImageCommand;
	
	import org.puremvc.as3.patterns.facade.Facade;

	public class ApplicationFacade extends Facade
	{
		public static const STARTUP : String = "startup";
		public static const LOAD_DEFINITION : String = "loadDefinition";
		public static const CREATE_SEQUENCE : String = "createSequence";
		public static const SEQUENCE_CREATED : String = "sequenceCreated";
		public static const SET_PREVIEW_IMAGES : String = "setPreviewImages";
		public static const SET_KERNELS : String = "setKernels";
		public static const EXECUTE_SEQUENCE : String = "executeSequence";
		public static const START_SEQUENCE : String = "startSequence";
		public static const STOP_SEQUENCE : String = "stopSequence";
		public static const SET_FRAMERATE : String = "setFrameRate";
		public static const RESET_ASSETS : String = "resetAssets";
		public static const SET_ASYNCHRONOUS : String = "setAsynchronous";
		public static const REQUEST_IMPORT_XML : String = "requestImportXML";
		public static const REQUEST_IMAGE_UPLOAD : String = "requestImageUpload";
		public static const UPDATE_ASSET : String = "updateAsset";
		
		
		public static function getInstance() : ApplicationFacade
		{
			if (!instance) instance = new ApplicationFacade();
			return instance as ApplicationFacade;
		}
		
		public function startup(application : RenderBender) : void
		{
			sendNotification(STARTUP, application);
			sendNotification(LOAD_DEFINITION, "xml/default.xml");
		}
		
		override protected function initializeController() : void
		{
			super.initializeController();
			registerCommand(STARTUP, StartupCommand);
			registerCommand(LOAD_DEFINITION, LoadDefinitionCommand);
			registerCommand(CREATE_SEQUENCE, CreateSequenceCommand);
			registerCommand(EXECUTE_SEQUENCE, ExecuteSequenceCommand);
			registerCommand(RESET_ASSETS, ResetAssetsCommand);
			registerCommand(SET_ASYNCHRONOUS, SetAsynchronousCommand);
			registerCommand(REQUEST_IMPORT_XML, BrowseXMLCommand);
			registerCommand(REQUEST_IMAGE_UPLOAD, UploadImageCommand);
		}
	}
}